// $ANTLR 3.4 ./src/main/java/hero/antlr2/TreeWalker.g 2011-12-03 21:48:53
package hero.antlr2;

import org.antlr.runtime.*;
import org.antlr.runtime.tree.*;
import java.util.Stack;
import java.util.List;
import java.util.ArrayList;

@SuppressWarnings({"all", "warnings", "unchecked"})
public class TreeWalker extends TreeParser {
    public static final String[] tokenNames = new String[] {
        "<invalid>", "<EOR>", "<DOWN>", "<UP>", "DOC", "ID", "INT", "NEWLINE", "SHIT", "TITLE", "WS"
    };

    public static final int EOF=-1;
    public static final int DOC=4;
    public static final int ID=5;
    public static final int INT=6;
    public static final int NEWLINE=7;
    public static final int SHIT=8;
    public static final int TITLE=9;
    public static final int WS=10;

    // delegates
    public TreeParser[] getDelegates() {
        return new TreeParser[] {};
    }

    // delegators


    public TreeWalker(TreeNodeStream input) {
        this(input, new RecognizerSharedState());
    }
    public TreeWalker(TreeNodeStream input, RecognizerSharedState state) {
        super(input, state);
    }

    public String[] getTokenNames() { return TreeWalker.tokenNames; }
    public String getGrammarFileName() { return "./src/main/java/hero/antlr2/TreeWalker.g"; }



    // $ANTLR start "prog"
    // ./src/main/java/hero/antlr2/TreeWalker.g:12:1: prog : ( stat )+ ;
    public final void prog() throws RecognitionException {
        try {
            // ./src/main/java/hero/antlr2/TreeWalker.g:12:5: ( ( stat )+ )
            // ./src/main/java/hero/antlr2/TreeWalker.g:12:9: ( stat )+
            {
            // ./src/main/java/hero/antlr2/TreeWalker.g:12:9: ( stat )+
            int cnt1=0;
            loop1:
            do {
                int alt1=2;
                int LA1_0 = input.LA(1);

                if ( ((LA1_0 >= ID && LA1_0 <= INT)) ) {
                    alt1=1;
                }


                switch (alt1) {
            	case 1 :
            	    // ./src/main/java/hero/antlr2/TreeWalker.g:12:9: stat
            	    {
            	    pushFollow(FOLLOW_stat_in_prog46);
            	    stat();

            	    state._fsp--;


            	    }
            	    break;

            	default :
            	    if ( cnt1 >= 1 ) break loop1;
                        EarlyExitException eee =
                            new EarlyExitException(1, input);
                        throw eee;
                }
                cnt1++;
            } while (true);


            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }

        finally {
        	// do for sure before leaving
        }
        return ;
    }
    // $ANTLR end "prog"



    // $ANTLR start "stat"
    // ./src/main/java/hero/antlr2/TreeWalker.g:13:1: stat : atom2= atom NEWLINE ;
    public final void stat() throws RecognitionException {
        int atom2 =0;


        try {
            // ./src/main/java/hero/antlr2/TreeWalker.g:13:5: (atom2= atom NEWLINE )
            // ./src/main/java/hero/antlr2/TreeWalker.g:13:9: atom2= atom NEWLINE
            {
            pushFollow(FOLLOW_atom_in_stat58);
            atom2=atom();

            state._fsp--;


            match(input,NEWLINE,FOLLOW_NEWLINE_in_stat60); 

             System.out.println("atom2 value is " + atom2); 

            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }

        finally {
        	// do for sure before leaving
        }
        return ;
    }
    // $ANTLR end "stat"



    // $ANTLR start "atom"
    // ./src/main/java/hero/antlr2/TreeWalker.g:17:1: atom returns [int value] : ( INT | ID );
    public final int atom() throws RecognitionException {
        int value = 0;


        CommonTree INT1=null;
        CommonTree ID2=null;


            System.out.println("init");
          
        try {
            // ./src/main/java/hero/antlr2/TreeWalker.g:24:3: ( INT | ID )
            int alt2=2;
            int LA2_0 = input.LA(1);

            if ( (LA2_0==INT) ) {
                alt2=1;
            }
            else if ( (LA2_0==ID) ) {
                alt2=2;
            }
            else {
                NoViableAltException nvae =
                    new NoViableAltException("", 2, 0, input);

                throw nvae;

            }
            switch (alt2) {
                case 1 :
                    // ./src/main/java/hero/antlr2/TreeWalker.g:25:5: INT
                    {
                    INT1=(CommonTree)match(input,INT,FOLLOW_INT_in_atom97); 

                    value = Integer.parseInt((INT1!=null?INT1.getText():null));

                    }
                    break;
                case 2 :
                    // ./src/main/java/hero/antlr2/TreeWalker.g:26:9: ID
                    {
                    ID2=(CommonTree)match(input,ID,FOLLOW_ID_in_atom109); 

                     System.out.println((ID2!=null?ID2.getText():null)); value = 10; 

                    }
                    break;

            }

                System.out.println("after");
              
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }

        finally {
        	// do for sure before leaving
        }
        return value;
    }
    // $ANTLR end "atom"

    // Delegated rules


 

    public static final BitSet FOLLOW_stat_in_prog46 = new BitSet(new long[]{0x0000000000000062L});
    public static final BitSet FOLLOW_atom_in_stat58 = new BitSet(new long[]{0x0000000000000080L});
    public static final BitSet FOLLOW_NEWLINE_in_stat60 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_INT_in_atom97 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_ID_in_atom109 = new BitSet(new long[]{0x0000000000000002L});

}